package com.qf.testShiro;

import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authc.UsernamePasswordToken;
import org.apache.shiro.mgt.DefaultSecurityManager;
import org.apache.shiro.realm.text.IniRealm;
import org.apache.shiro.subject.Subject;

/**
 * @ClassName test
 * @Author xiao宋
 * @Date 11:54  2022/10/10
 * @Version 1.0
 * @Description TODO
 */
public class test {
    public static void main(String[] args) {


        DefaultSecurityManager manager = new DefaultSecurityManager();
        IniRealm iniRealm = new IniRealm("classpath:shiro.ini");
        manager.setRealm(iniRealm);
        SecurityUtils.setSecurityManager(manager);
        Subject subject = SecurityUtils.getSubject();
        UsernamePasswordToken token = new UsernamePasswordToken("xiaoming","123");
        subject.login(token);
        System.out.println("是否是已经认证"+subject.isAuthenticated());
        System.out.println("是否是dadmin角色"+subject.hasRole("admin"));
        System.out.println("是否是test角色"+subject.hasRole("test"));
        System.out.println("是否具有瞎编的权限"+subject.isPermitted("sys:System:query"));
        System.out.println("是否具有瞎编的权限"+subject.isPermitted("shop:dac"));
    }
}
